
#include "nb_api.h"
#include "BleDrive.h"

extern char GetConnectedStatus(void);
unsigned char SleepStatus = 2;	 //1-sleep, 2-stop, 0-running

/////////////////////Following functions are porting functions/////////////////////////////////
/* porting functions----------------------------------------------------------*/
void SPI_CS_Enable_(void)
{	
	BLE_NSS_RESET();
}

void SPI_CS_Disable_(void)
{
	BLE_NSS_SET();
}

char IsIrqEnabled(void)
{
	return 1;
}

unsigned char SPI_WriteRead(unsigned char SendData)
{
	while ((SPI1->STS & SPI_I2S_TE_FLAG) == 0)
		;
	
  SPI1->DAT = SendData;

  /*!< Wait to receive a byte */
  while ((SPI1->STS & SPI_I2S_RNE_FLAG) == 0)
        ;

  /*!< Return the byte read from the SPI bus */
  return SPI1->DAT;
  
}

//////DO NOT REMOVE, used in ble lib///////
void SysClk8to48(void)
{
}
void SysClk48to8(void)
{
}

void DisableEnvINT(void)
{ 
}
void EnableEnvINT(void)
{
}

void UpdateLEDValueAll(void) 
{
}

void McuGotoSleepAndWakeup(void) // auto goto sleep AND wakeup, porting api
{
    
}

void IrqMcuGotoSleepAndWakeup(void)
{
    if(ble_run_interrupt_McuCanSleep())
    {
        //ble_run_interrupt_McuCanSleep();
    }
}
